package com.common.tag;

import java.io.IOException;
import java.util.Map;

import javax.servlet.jsp.JspException;
import javax.servlet.jsp.JspWriter;

import com.common.util.StringUtil;

public class ReportObjMapping extends BaseTag {


	
	private Object items;
	private String topTitleVal;
	
	private String titlesVal;
	private String mentsVal;
	
	public String getMentsVal() {
		return mentsVal;
	}
	public void setMentsVal(String mentsVal) {
		this.mentsVal = mentsVal;
	}
	public String getTitlesVal() {
		return titlesVal;
	}
	public void setTitlesVal(String titlesVal) {
		this.titlesVal = titlesVal;
	}
	public Object getItems() {
		return items;
	}
	public void setItems(Object items) {
		this.items = items;
	}

	
	@Override
	public int doStartTag() throws JspException {
		JspWriter out = pageContext.getOut();
		StringBuilder outStr = new StringBuilder("");
		Map map = null;
		map = (Map) items;
		
		if(map!=null){
		if(!StringUtil.isBlank(titlesVal)&&!StringUtil.isBlank(mentsVal)){
			if(!StringUtil.isBlank(topTitleVal)){
				titlesVal = topTitleVal+"-"+titlesVal;
			}
			if(!StringUtil.isBlank(map.get(titlesVal+"_"+mentsVal))){
				outStr.append(map.get(titlesVal+"_"+mentsVal));
			}else{
				outStr.append("0");
			}
			
		}
		try {
			out.write(outStr.toString());
		} catch (IOException e) {
			log.error(e.getMessage());
		}
		}
		return SKIP_PAGE;
	}
	public String getTopTitleVal() {
		return topTitleVal;
	}
	public void setTopTitleVal(String topTitleVal) {
		this.topTitleVal = topTitleVal;
	}
	
}
